home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / objeas3a / demos / viddemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-18  |  9.5 KB  |  365 lines

  1. //**************************************************************************
  2. //      This is a demo program to show how to use some of the features of
  3. //      the VIDBIOS libraries of the ObjectEase package. To compile and run
  4. //      this program create a project file including the files TUI30.LIB,
  5. //      (use TUI40.LIB if you are using Borland C++ 4.0) VIDBIOS3.LIB, 
  6. //      (use VIDBIOS4.LIB if you are using Borland C++ 4.0)
  7. //      and VIDDEMO.CPP. Make sure that these files are located
  8. //      where the project says they are. You may also need to modify the path
  9. //      to the files VIDBIOS.H and TUI.H in the #includes portion of this
  10. //      file.
  11. //
  12. //      BE SURE YOU ARE COMPILING FOR THE LARGE MEMORY MODEL!!!
  13. //**************************************************************************
  14.  
  15. #include "d:\tui\tui.h"
  16. #include "d:\vidbios\vidbios.h"
  17. #include <conio.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20.  
  21. //*************************  FUNCTION PROTOTYPES  **************************
  22.  
  23. void intro();
  24. void demo1();
  25. void demo2();
  26. void demo3();
  27. void demo4();
  28. void demo5();
  29. void demo6();
  30. void outro();
  31.  
  32. //***************************  GLOBAL VARIABLES  ***************************
  33.  
  34. unsigned char def_pal[17];
  35. extern Mcursor the_mouse;
  36.  
  37. //**************************************************************************
  38. //              MAIN
  39. //**************************************************************************
  40.  
  41. void main()
  42. {
  43.     the_mouse.init();
  44.     cursoroff();
  45.     settext(7,0);
  46.     clrscr();
  47.     intro();
  48.     demo1();
  49.     settext(7,0);
  50.     clrscr();
  51.     demo2();
  52.     settext(7,0);
  53.     clrscr();
  54.     demo3();
  55.     settext(7,0);
  56.     clrscr();
  57.     demo4();
  58.     settext(7,0);
  59.     clrscr();
  60.     demo5();
  61.     settext(7,0);
  62.     clrscr();
  63.     demo6();
  64.     clear(32,0,0);
  65.     dlay(18);
  66.  
  67.     settext(7,0);
  68.     clrscr();
  69.     cursoron();
  70.     puts("Thank you for previewing the ObjectEase library from");
  71.     puts("David S. Reinhart Associates");
  72.     exit(0);
  73. }
  74.  
  75. //*************************************************************************
  76.  
  77. void intro()
  78. {
  79.     Twindow introwindow;
  80.     introwindow.init(4,6,77,18,14,2,0,0);
  81.     introwindow.title("Introduction");
  82.     introwindow.show();
  83.  
  84.     printc(8,14,2,"This short demo program highlights the video bios features of the");
  85.     printc(9,14,2,"ObjectEase library. Note that these library functions will work ONLY on");
  86.     printc(10,14,2,"VGA cards. If the program you are developing is intended for use on");
  87.     printc(11,14,2,"a variety of video equipment, be sure to test for the existence of");
  88.     printc(12,14,2,"a VGA card before calling these functions. If using an accelerated");
  89.     printc(13,14,2,"video card the fade routines will happen too quickly to be" );
  90.     printc(14,14,2,"appreciated. They will work fine on any standard VGA card.");
  91.     printc(16,15,2,"Press any key now to get on with the show...");
  92.  
  93.     getch();
  94.     introwindow.hide();
  95.     flushkeys();
  96. }
  97.  
  98. //*************************************************************************
  99.  
  100. void demo1()
  101. {
  102.     Twindow demo1window;
  103.  
  104.     demo1window.init(40,8,76,13,15,1,0,0);
  105.     demo1window.show();
  106.     printat(42,10,15,1," Fade any individual palette color");
  107.     printat(42,11,15,1,"     in and out as desired.     ");
  108.  
  109.     printat(5,5,1,0,"Blue         ████████");
  110.     printat(5,6,2,0,"Green        ████████");
  111.     printat(5,7,3,0,"Cyan         ████████");
  112.     printat(5,8,4,0,"Red          ████████");
  113.     printat(5,9,5,0,"Magenta      ████████");
  114.     printat(5,10,6,0,"Brown        ████████");
  115.     printat(5,11,7,0,"Lt. Gray     ████████");
  116.     printat(5,12,8,0,"Dk. Gray     ████████");
  117.     printat(5,13,9,0,"Br. Blue     ████████");
  118.     printat(5,14,10,0,"Br. Green    ████████");
  119.     printat(5,15,11,0,"Br. Cyan     ████████");
  120.     printat(5,16,12,0,"Br. Red      ████████");
  121.     printat(5,17,13,0,"Br. Magenta  ████████");
  122.     printat(5,18,14,0,"Yellow       ████████");
  123.     printat(5,19,15,0,"White        ████████");
  124.  
  125.     delay(1500);
  126.     for(int i=1;i<16;i++) {
  127.         fadeout(i);
  128.         fadein(i);
  129.         }
  130.     demo1window.fill();
  131.     printat(42,11,15,1,"         Press any key...   ");
  132.     getch();
  133.     flushkeys();
  134.     demo1window.hide();
  135. }
  136.  
  137. //**************************************************************************
  138.  
  139. void demo2()
  140. {
  141.     Twindow demo2window;
  142.     demo2window.init(20,5,61,10,15,1,0,0);
  143.     demo2window.show();
  144.     printc(7,15,1,"Instantly set any color to black,");
  145.     printc(8,15,1,"then fade in when appropriate.");
  146.  
  147.     Twindow greenwindow;
  148.     Twindow cyanwindow;
  149.     Twindow redwindow;
  150.     Twindow magentawindow;
  151.     Twindow brownwindow;
  152.  
  153.     greenwindow.init(15,12,25,17,2,2,0,0);
  154.     blankcolor(2);
  155.     cyanwindow.init(25,12,35,17,3,3,0,0);
  156.     blankcolor(3);
  157.     redwindow.init(35,12,45,17,4,4,0,0);
  158.     blankcolor(4);
  159.     magentawindow.init(45,12,55,17,5,5,0,0);
  160.     blankcolor(5);
  161.     brownwindow.init(55,12,65,17,6,6,0,0);
  162.     blankcolor(6);
  163.  
  164.     greenwindow.show();
  165.     cyanwindow.show();
  166.     redwindow.show();
  167.     magentawindow.show();
  168.     brownwindow.show();
  169.  
  170.     delay(1500);
  171.     fadein(2);
  172.     delay(500);
  173.     fadein(3);
  174.     delay(500);
  175.     fadein(4);
  176.     delay(500);
  177.     fadein(5);
  178.     delay(500);
  179.     fadein(6);
  180.     delay(500);
  181.  
  182.     demo2window.fill();
  183.     printc(8,15,1,"Press any key...");
  184.     getch();
  185.     flushkeys();
  186.     brownwindow.hide();
  187.     magentawindow.hide();
  188.     redwindow.hide();
  189.     cyanwindow.hide();
  190.     greenwindow.hide();
  191.     demo2window.hide();
  192. }
  193.  
  194. //**************************************************************************
  195.  
  196. void demo3()
  197. {
  198.     Twindow demo3window;
  199.  
  200.     demo3window.init(10,5,71,7,15,2,0,0);
  201.     demo3window.show();
  202.     printc(6,15,2,"\"Slide\" from one color into the next for exciting effects!");
  203.  
  204.     Twindow slidewindow;
  205.     slidewindow.init(20,12,61,22,1,1,0,0);
  206.     slidewindow.show();
  207.     delay(1000);
  208.     fade1_3();
  209.     delay(500);
  210.     fade3_1();
  211.     delay(500);
  212.     fade1_4();
  213.     delay(500);
  214.     fade4_1();
  215.     delay(500);
  216.     fade1_5();
  217.     delay(500);
  218.     fade5_1();
  219.     delay(500);
  220.  
  221.     demo3window.fill();
  222.     printc(6,15,2,"Press any key...");
  223.     getch();
  224.     flushkeys();
  225.     slidewindow.hide();
  226.     demo3window.hide();
  227. }
  228.  
  229. //**************************************************************************
  230.  
  231. void demo4()
  232. {
  233.     Twindow demo4window;
  234.     int r,g,b,i;
  235.  
  236.     demo4window.init(40,5,75,14,15,1,0,0);
  237.     demo4window.show();
  238.     printat(42,7,15,1,"   Bored with the standard 16");
  239.     printat(42,8,15,1,"         color palette?");
  240.     printat(42,10,15,1,"           CHANGE IT!");
  241.  
  242.     printat(5,5,1,0,"Color 1      ████████");
  243.     printat(5,6,2,0,"Color 2      ████████");
  244.     printat(5,7,3,0,"Color 3      ████████");
  245.     printat(5,8,4,0,"Color 4      ████████");
  246.     printat(5,9,5,0,"Color 5      ████████");
  247.     printat(5,10,6,0,"Color 6      ████████");
  248.     printat(5,11,7,0,"Color 7      ████████");
  249.     printat(5,12,8,0,"Color 8      ████████");
  250.     printat(5,13,9,0,"Color 9      ████████");
  251.     printat(5,14,10,0,"Color 10     ████████");
  252.     printat(5,15,11,0,"Color 11     ████████");
  253.     printat(5,16,12,0,"Color 12     ████████");
  254.     printat(5,17,13,0,"Color 13     ████████");
  255.     printat(5,18,14,0,"Color 14     ████████");
  256.     printat(5,19,15,0,"Color 15     ████████");
  257.  
  258.     delay(3000);
  259.     printat(42,12,15,1,"     Press any key to end...");
  260.     flushkeys();
  261.     while(!kbhit()) {
  262.         for(i=1;i<16;i++)
  263.             rgb(i,random(63),random(63),random(63));
  264.         delay(1000);
  265.         }
  266.     set_default_palette();
  267.     delay(2000);
  268.     demo4window.hide();
  269. }
  270.  
  271. //**************************************************************************
  272.  
  273. void demo5()
  274. {
  275.     Twindow demo5window;
  276.  
  277.     demo5window.init(5,5,76,12,15,1,0,0);
  278.     demo5window.show();
  279.  
  280.     printc(7,15,1,"As you know, if you try to use colors 8 through 15 as");
  281.     printc(8,15,1,"background colors, the foreground begins to blink against your will.");
  282.     delay(2000);
  283.     printc(10,14,1,"Well now you're in control!");
  284.  
  285.     disable_blink();
  286.     delay(1000);
  287.     printc(15,0,15,"     Black on white    ");
  288.     delay(1000);
  289.     printc(17,5,14,"   Magenta on yellow   ");
  290.     delay(1000);
  291.     printc(19,15,9,"    Any combination!   ");
  292.     delay(2000);
  293.  
  294.     printc(22,15,0,"Press any key...");
  295.  
  296.     flushkeys();
  297.     getch();
  298.     enable_blink();
  299.     demo5window.hide();
  300. }
  301.  
  302. //**************************************************************************
  303.  
  304. void demo6()
  305. {
  306.     Twindow demo6window;
  307.     demo6window.init(5,5,76,13,15,1,0,0);
  308.     demo6window.show();
  309.  
  310.     printc(7,15,1,"Ever want to turn the screen off during a massive screen");
  311.     printc(8,15,1,"drawing routine so that the user doesn't have to (or doesn't");
  312.     printc(9,15,1,"get to) see it all happening?");
  313.     delay(3000);
  314.     printc(11,14,1,"Press any key to DO IT!");
  315.  
  316.     flushkeys();
  317.     getch();
  318.     flushkeys();
  319.     disable_refresh();
  320.     demo6window.hide();
  321.  
  322.     Twindow w1,w2,w3,w4,w5;
  323.     w1.init(15,5,25,10,15,1,1,7);
  324.     w1.show();
  325.     w2.init(25,7,35,12,15,2,1,7);
  326.     w2.show();
  327.     w3.init(35,9,45,14,15,3,1,7);
  328.     w3.show();
  329.     w4.init(45,11,55,16,15,4,1,7);
  330.     w4.show();
  331.     w5.init(55,13,65,18,15,5,1,7);
  332.     w5.show();
  333.  
  334.     delay(1000);
  335.     enable_refresh();
  336.     delay(1500);
  337.  
  338.     printc(22,15,0,"Press any key...");
  339.     flushkeys();
  340.     getch();
  341. }
  342.  
  343. //**************************************************************************
  344.  
  345. void outro()
  346. {
  347.     Twindow outrowindow;
  348.     outrowindow.init(4,6,77,18,14,2,0,0);
  349.     outrowindow.title("Summary");
  350.     outrowindow.show();
  351.  
  352.     printc(8,14,2,"These are the highlights...the raw materials for your");
  353.     printc(9,14,2,"creative ideas. Note that while this demo was in text mode,");
  354.     printc(10,14,2,"these functions work equally as well in graphics mode.");
  355.     printc(11,14,2,"Please read the complete documentation file for specific");
  356.     printc(12,14,2,"information on using these functions in your programs.");
  357.     printc(14,14,2,"Thank you for previewing software from Ludicrous Data.");
  358.     printc(16,15,2,"Press any key now to return to DOS...");
  359.  
  360.     flushkeys();
  361.     getch();
  362.     flushkeys();
  363.     outrowindow.hide();
  364. }
  365.